package com.example.mytestdemo.customviewbook.six.scrollerdemo;

import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import com.example.mytestdemo.R;

public class SixScrollerActivity extends AppCompatActivity implements View.OnClickListener {

    private static final int DISTANCE = 300;
    private ScrollerLinearLayout mScrollerLayout;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.six_activity_scroller);

        findViewById(R.id.btn_start).setOnClickListener(this);
        findViewById(R.id.btn_reset).setOnClickListener(this);

        mScrollerLayout = findViewById(R.id.scroller_root);
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        switch (id) {
        case R.id.btn_start: {
            mScrollerLayout.startScroll(0, DISTANCE);
        }
        break;
        case R.id.btn_reset: {
            mScrollerLayout.startScroll(DISTANCE, -DISTANCE);
        }
        break;
        }
    }
}
